package com.xyzwps.harbor.handler.validator;

public final class Validators {

    @SafeVarargs
    public static <T> ValidateFunction<T> sequential(ValidateFunction<T>... functions) {

        if (functions == null || functions.length == 0) {
            throw new IllegalArgumentException("sequential varargs cannot be empty" );
        }

        for (int i = 0; i < functions.length; i++) {
            if (functions[i] == null) {
                throw new IllegalArgumentException("functions[" + i + "] cannot be null" );
            }
        }

        return (T t) -> {
            for (var func : functions) {
                func.validate(t);
            }
        };
    }


}
